#!/user/bin/python
# -*- coding:utf-8 -*-
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider

class DBUtil:
    def __init__(self, username='root', password='123456', ipAddress='192.168.100.104'):
        self.username = username


# 获取认证
def get_auth():
    # 口令
    return PlainTextAuthProvider(username='root', password='123456')

# 获取cassandra集群
def get_cluster():
    # 创建集群
    return Cluster(contact_points=['192.168.100.104'], auth_provider=get_auth())

# 获取cassandra数据库连接
def get_connection():
    # 获取数据库连接
    return get_cluster().connect()


